/**
 * Created with JetBrains WebStorm.
 * User: Eric
 * Date: 02/02/13
 * Time: 17:33
 * To change this template use File | Settings | File Templates.
 *
 *
 */


/*
 * this is a test file for design a Dao pattern like in Java.
 * This is the model of user
 */
var Weapon = function Weapon(){

}

Weapon.prototype = {
    initialize : function() {
        this.id;
        this.name,
        this.requirement,
        this.damage,
        this.cadence,
        this.price,
        this.precision
    },

    /*
     *This function will take the rows of the SQL query and hydrate the user
     */
    init : function(parameters){""

        var id = parameters.id;
        this.id = parameters.id;
        this.name = parameters.name;
        this.requirement = parameters.requirement;
        this.damage = parameters.damage;
        this.cadence = parameters.cadence;
        this.price = parameters.price;
        this.precision = parameters.precision;
    },

    /*
     * Example of method of the object (the attributes of this object are public so getter is useless)
     */
    getId : function(){
        return this.id;
    },

    getName : function(){
        return this.name;
    },

    getRequirement : function(){
        return this.requirement;
    },

    getDamage : function(){
        return this.damage;
    },

    getCadence : function(){
        return this.cadence;
    },

    getPrice : function(){
        return this.price;
    },

    getPrecision : function(){
        return this.precision;
    },

    getWeaponForPersist : function(){


        if(this.weapon == null){

            return null;
        }
        if(this.weapon.id == undefined){

            return this.weapon;
        }else{
            return this.weapon.id;
        }

    }

}

/*
 * We export the class user so we ca use it after requiring this file.
 */
module.exports = Weapon;